using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using UnityEngine.UIElements;

public class screwItem : MonoBehaviour
{
    public Animator ani;

    internal Color getColor()
    {
        return GetComponent<MeshRenderer>().material.color;
    }

    public pedestalItem my_PedestalItem;
    internal void SetPos(Vector3 position, int count, pedestalItem pedestalItem)
    {
        my_PedestalItem = pedestalItem;

        transform.DOMove(position, 0.5f).OnComplete(() =>
        {
            if (count >= 5)
            {
                if (pedestalItem.HasDes())
                {
                    pedestalItem.RemoveAll();
                }
            }
        });

        ani.SetTrigger("ISMove");
    }
    private void Awake()
    {
        var index = Random.Range(0, 2);

        switch (index)
        {
            case 1:
                GetComponent<MeshRenderer>().material.color = Color.blue;
                break;
            default:
                GetComponent<MeshRenderer>().material.color = Color.red;
                break;
        }
    }
    // Start is called before the first frame update
    void Start()
    {

        ani = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {

    }

    internal void DesThis()
    {
        ani.SetTrigger("ISMove");

        transform.DOMove(transform.position + Vector3.up * 5, 0.5f).OnComplete(() =>
        {
            Destroy(gameObject);
        });

    }
}
